package edu.usm.roberge.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.HasData;

import edu.usm.roberge.shared.WeatherForecast;

public class WeatherView extends Composite {

	private static WeatherViewUiBinder uiBinder = GWT
			.create(WeatherViewUiBinder.class);
	@UiField(provided=true) CellTable<WeatherForecast> cellTable = new CellTable<WeatherForecast>();
	@UiField AirlinePriceView airlinePriceView;

	interface WeatherViewUiBinder extends UiBinder<Widget, WeatherView> {
	}

	public WeatherView() {
		initWidget(uiBinder.createAndBindUi(this));
		cellTable.addColumn(new TextColumn<WeatherForecast>() {

			@Override
			public String getValue(WeatherForecast object) {
				return object.getTime();
			}
		}, "Day");
		
		cellTable.addColumn(new TextColumn<WeatherForecast>() {

			@Override
			public String getValue(WeatherForecast object) {
				return object.getWeather() + " " + object.getTemperature() + " F";
			}
		}, "Forecast");
	}

	public HasData<String> getAirlinePriceView() {
		return airlinePriceView.getCellList();
	}

	public HasData<WeatherForecast> getCellTable() {
		return cellTable;
	}
}
